﻿using FastReport;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZK.Qymd_TransManage.Model;

namespace ZK.Qymd_TransManage
{
    public partial class ManualPrint : Form
    {
        private List<DataGridModel> FBusinessObject;
        public ManualPrint()
        {
            InitializeComponent();
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            DataGridModel bill = new DataGridModel();
            bill.TruckNum = txtTruckNum.Text;
            if (txtGrossWeight.Text != ""&& txtGrossWeight.Text != null) {
                bill.GrossWeight = txtGrossWeight.Text;
            }
            if (txtTare.Text != "" && txtTare.Text != null)
            {
                bill.Tare = txtTare.Text;
            }
            if (txtNetWeight.Text != "" && txtNetWeight.Text != null)
            {
                bill.NetWeight = txtNetWeight.Text;
            }
            bill.CoalType = txtCoalType.Text;
            bill.ShipperName = txtShipperName.Text;
            bill.ReceivingPartyName = txtReceivingPartyName.Text;
            bill.TransportUnit = txtTransportUnit.Text;
            bill.GrossWeightTime = txtGrossWeightTime.Text;
            bill.TareTime = txtTareTime.Text;
            bill.GrossWeightUser = txtGrossWeightUser.Text;
            bill.TareUser = txtTareUser.Text;
            bill.WeighDate = txtWeighDate.Text;
            bill.name = Login.name;
            FBusinessObject = new List<DataGridModel>();
            FBusinessObject.Add(bill);
            Report report = new Report();
            report.Load(@"QYMDBD.frx");
            report.RegisterData(FBusinessObject, "DataTable");
            // 预览打印
            //report.Show();

            //report.Dispose();
            //静默打印
            //report.PrintSettings.ShowDialog = false;
            report.Print();
        }

        private void kryptonButton1_Click(object sender, EventArgs e)
        {
            Invoke(new Action(() =>
            {
                txtTruckNum.Text = "";
                txtTare.Text = "";
                txtGrossWeight.Text = "";
                txtNetWeight.Text = "";
                txtCoalType.Text = "";
                txtShipperName.Text = "";
                txtReceivingPartyName.Text = "";
                txtTransportUnit.Text = "";
                txtGrossWeightTime.Text = "";
                txtTareTime.Text = "";
                txtGrossWeightUser.Text = "";
                txtTareUser.Text = "";
                txtWeighDate.Text = "";
                txtNum.Text = "";
            }));
        }
    }
}
